#include <iostream>
#include <string>
#include <unordered_set>
using namespace std;

int lengthOfLongestSubstring(string s) {
    if(s.length() == 0) return 0;
    if(s.length() == 1) return 1;
    unordered_set<char> us;
    int left = 0;
    int ans = 1;
    us.insert(s[0]);
    for(int i=1;i<s.length();i++){
        if(us.find(s[i]) == us.end()){
            us.insert(s[i]);
            ans = max(ans, i - left + 1);
        }else{
            while(us.find(s[i])  != us.end()){
                us.erase(s[left]);
                left++;
            }
            us.insert(s[i]);
        }
    }
    return ans;
}

int main(){
    string s = "pwwkew";
    int ans = lengthOfLongestSubstring(s);
    cout << ans << endl;
}